CFLAGS += $(addprefix -I,$(LOCAL_INC_DIR))

ifeq ($(COMPILE_SO), y)
LOCAL_SHARED_LIB := plat_common plat_thread \
				app_net
PLAT_STATIC_LIB :=
MPI_STATIC_LIB := 
APP_STATIC_LIB :=
else
APP_STATIC_LIB := app_net
PLAT_STATIC_LIB := plat_common
LOCAL_SHARE_LIB := pthread m dl
endif

LACAL_SHARE_LIB_FLAGS := $(addprefix -l, $(patsubst lib%, %, $(LOCAL_SHARE_LIB)))
LACAL_STATIC_LIB_FLAGS := $(addprefix $(APP_LIB_DIR)/, $(patsubst %, lib%.a, $(APP_STATIC_LIB)))
LACAL_STATIC_LIB_FLAGS += $(addprefix $(PLAT_LIB_DIR)/, $(patsubst %, lib%.a, $(PLAT_STATIC_LIB)))

LOCAL_LDFLAGS := -L$(PLAT_LIB_DIR) -L$(MPI_LIB_DIR) -L$(APP_LIB_DIR)

LDFLAGS := $(LACAL_STATIC_LIB_FLAGS)
LDFLAGS += $(LACAL_SHARE_LIB_FLAGS)
LDFLAGS += $(addprefix -l,$(patsubst lib%,%,$(LOCAL_SHARED_LIB)))
LDFLAGS += $(LOCAL_LDFLAGS)
LDFLAGS += $(STD_LDFLAGS)

all: discovery cmd

discovery:discovery.o 
	@$(CC) -o discovery discovery.o $(CFLAGS) $(LDFLAGS) $(LIBS)
	$(STRIP) discovery

cmd:cmd.o 
	@$(CC) -o cmd cmd.o $(CFLAGS) -lpthread -lm $(LIBS)
	$(STRIP) cmd

%.o : %.c
	@$(CC) $(CFLAGS) -c $< -o $@
	@echo ""

install:
	@$(CP) discovery cmd $(ROOTFS_BIN_DIR)

clean:
	@$(RM) *.o
	@$(RM) discovery cmd *~

PHONY: all clean install
